<%@ page import="com.example.cdpbookstore.service.BookService" %>
<%@ page import="com.example.cdpbookstore.service.impl.BookServiceImpl" %>
<%@ page import="com.example.cdpbookstore.pojo.entity.Book" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>

<%
    BookService bookService = new BookServiceImpl();

    String bookId = request.getParameter("book");
    Book book;
    if (bookId != null) {
        book = bookService.getById(Long.valueOf(bookId));
        pageContext.setAttribute("book", book);
    }
%>

<!DOCTYPE html>
<html lang="zh-Hans-CN">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>布克书店 - 图书详情</title>

    <link rel="icon" type="image/png" href="image/web-icon.png">
    <link rel="stylesheet" type="text/css" href="lib/font-awesome-6.5.2/css/all.css">
    <link rel="stylesheet" type="text/css" href="css/common/com-a.css">
    <link rel="stylesheet" type="text/css" href="css/common/com-b.css">
    <link rel="stylesheet" type="text/css" href="css/book.css">
</head>

<body>
<div class="main">
    <jsp:include page="common/header1.jsp"/>

    <!-- book detail 部分 -->
    <div class="bookDetail">
        <div class="bd-center">
            <div class="bd-left">
                <img src="/img/book/${book.images}" alt="">
            </div>
            <div class="bd-right">
                <h1 class="book-name">${book.bookName}</h1>
                <p class="author"><span>作者：</span><span class="book-info">${book.author}</span></p>
                <p class="press"><span>出版社：</span><span class="book-info">${book.press}</span></p>
                <p class="stock"><span>库存量：</span><span class="book-info">${book.stock}本</span></p>
                <p class="sales-volume"><span>销量：</span><span class="book-info">${book.salesVolume}本</span></p>
                <p class="isbn"><span>ISBN：</span><span class="book-info">${book.isbn}</span></p>
                <p></p>
                <div class="price">
                    <div class="current-price"><span>现价：</span><span>￥${book.currentPrice}</span></div>
                    <div class="discount"><span>(${book.discount}折)</span></div>
                    <div class="original-price"><span>原价：</span><span>￥${book.originalPrice}</span></div>
                </div>
                <div class="btnWrap">
                    <div class="btn btn-add"><a href="add-to-cart?id=${book.id}">加入购物车</a></div>
                    <div class="btn btn-buy"><a href="order-now?id=${book.id}&quantity=1">立即购买</a></div>
                </div>
            </div>
        </div>
    </div>

    <jsp:include page="common/footer1.jsp"/>
</div>
</body>

</html>
